import { IHospitalListData } from '@/api/hospital/hospitalList/model/hospitalListType';
import { Descriptions, Card, Button, Image } from 'antd';
import React from 'react';
import { useLocation, useNavigate, useParams } from 'react-router-dom';

export default function HospitalShow() {
  const location = useLocation();
  const {id } = useParams()
  const navigate = useNavigate();
  const data = location.state as IHospitalListData;

  return (
    <Card>
      <Descriptions title="基本信息" bordered column={2}>
        <Descriptions.Item label="医院名称">{data.hosname}</Descriptions.Item>
        <Descriptions.Item label="医院logo">
          <Image src={`data:image/jpeg;base64,${data.logoData}`} width={100}></Image>
        </Descriptions.Item>
        <Descriptions.Item label="医院编码">{data.hoscode}</Descriptions.Item>
        <Descriptions.Item label="医院地址">{data.param.fullAddress}</Descriptions.Item>
        <Descriptions.Item label="坐车路线" span={2}>
          {data.route}
        </Descriptions.Item>
        <Descriptions.Item label="医院简介">{data.intro}</Descriptions.Item>
      </Descriptions>

      <Descriptions title="预约规则信息" bordered column={2} style={{ marginTop: 20, marginBottom: 20 }}>
        <Descriptions.Item label="预约周期">{data.bookingRule.cycle + '天'}</Descriptions.Item>
        <Descriptions.Item label="放号时间">{data.bookingRule.releaseTime}</Descriptions.Item>
        <Descriptions.Item label="停挂时间">{data.bookingRule.stopTime}</Descriptions.Item>
        <Descriptions.Item label="退号时间">{data.bookingRule.quitTime}</Descriptions.Item>
        <Descriptions.Item label="预约规则" span={2}>
          {data.bookingRule.rule.map((item, index) => {
            return (
              <div key={index}>
                {index + 1}.{item}
              </div>
            );
          })}
        </Descriptions.Item>
      </Descriptions>

      <Button
        onClick={() => {
          navigate(-1);
        }}>
        返回
      </Button>
    </Card>
  );
}
